package com.google.memoryofaplace.model;

import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.beoui.geocell.GeocellManager;
import com.beoui.geocell.model.Point;

@PersistenceCapable
public class TBPlaces {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long codPlace;
	@Persistent
	private String name;
	@Persistent
	private String description;
	@Persistent
	private int type;
	@Persistent
	private int status;
	@Persistent
	private int categoryType;
	@Persistent
	private Date creation;
	@Persistent
	private Date update;
	@Persistent
	private Double latitude;
	@Persistent
	private Double longitude;
	@Persistent
	private String url;
	@Persistent
	private String userUpdate;
	@Persistent
	private String userCreation;
	@Persistent
	private String urlLogo;
	@Persistent
	private String urlStreetView;	
	@Persistent 
	List<String> geoCells;

	@Persistent
	private String address;	

	
	public List<String> getGeoCells() {
		return geoCells;
	}

	public void setGeoCells(List<String> geoCells) {
		this.geoCells = geoCells;
	}

	@Persistent
	List<TBPlaceMedia> media;

	@Persistent
	List<TBPlaceComments> comments;

	public TBPlaces(String name, String description, int type, int status,
			int categoryType, Double latitude, Double longitude,
			String urlStreetView, String url, String urlLogo, String user, String address) {
		super();
		this.name = name;
		this.description = description;
		this.type = type;
		// TODO poner por defecto el estado a published
		// this.status = Status.DRAFT.ordinal();
		// this.status = Status.PUBLISHED.getCode();
		this.categoryType = categoryType;
		this.creation = new Date();
		this.update = new Date();
		this.latitude = latitude;
		this.longitude = longitude;
		this.url = url;
		this.userCreation = user;
		this.userUpdate = user;
		this.address = address;
		Point p = new Point(latitude, longitude);
		List<String> cells = GeocellManager.generateGeoCell(p);
		this.geoCells = cells;
		this.urlLogo = urlLogo;
		this.urlStreetView = urlStreetView;
	}

	public void setCodPlace(Long codPlace) {
		this.codPlace = codPlace;
	}

	public Long getCodPlace() {
		return codPlace;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	public void setCreation(Date creation) {
		this.creation = creation;
	}

	public Date getCreation() {
		return creation;
	}

	public void setUpdate(Date update) {
		this.update = update;
	}

	public Date getUpdate() {
		return update;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getUrl() {
		return url;
	}

	public void setUserUpdate(String userUpdate) {
		this.userUpdate = userUpdate;
	}

	public String getUserUpdate() {
		return userUpdate;
	}

	public void setUserCreation(String userCreation) {
		this.userCreation = userCreation;
	}

	public String getUserCreation() {
		return userCreation;
	}

	public void setUrlLogo(String urlLogo) {
		this.urlLogo = urlLogo;
	}

	public String getUrlLogo() {
		return urlLogo;
	}

	public void setUrlStreetView(String urlStreetView) {
		this.urlStreetView = urlStreetView;
	}

	public String getUrlStreetView() {
		return urlStreetView;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getStatus() {
		return status;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getType() {
		return type;
	}

	public void setCategoryType(int categoryType) {
		this.categoryType = categoryType;
	}

	public int getCategoryType() {
		return categoryType;
	}

	public List<TBPlaceMedia> getMedia() {
		return media;
	}

	public List<TBPlaceComments> getComments() {
		return comments;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getAddress() {
		return address;
	}
	

}
